package Operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created by xiebang
 * Description
 * User:小谢
 * Date:2021-09-21
 * Time:21:07
 */
public class SearchOperation implements IOperation{

    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书！");
        System.out.println("请输入你要查找书的名字");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int size = bookList.getBookSize();
        for (int i = 0; i < size; i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)){
                System.out.println("查找成功！");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有该书籍");
    }

}
